// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.skinnedmodel.advancedanimation;

import zombie.core.math.PZMath;
import zombie.util.StringUtils;

public final class AnimationVariableSlotCallbackString extends AnimationVariableSlotCallback<String> {
    private String m_defaultValue = "";

    public AnimationVariableSlotCallbackString(String key, AnimationVariableSlotCallbackString.CallbackGetStrongTyped callbackGet) {
        super(key, callbackGet);
    }

    public AnimationVariableSlotCallbackString(
        String key,
        AnimationVariableSlotCallbackString.CallbackGetStrongTyped callbackGet,
        AnimationVariableSlotCallbackString.CallbackSetStrongTyped callbackSet
    ) {
        super(key, callbackGet, callbackSet);
    }

    public AnimationVariableSlotCallbackString(String key, String defaultVal, AnimationVariableSlotCallbackString.CallbackGetStrongTyped callbackGet) {
        super(key, callbackGet);
        this.m_defaultValue = defaultVal;
    }

    public AnimationVariableSlotCallbackString(
        String key,
        String defaultVal,
        AnimationVariableSlotCallbackString.CallbackGetStrongTyped callbackGet,
        AnimationVariableSlotCallbackString.CallbackSetStrongTyped callbackSet
    ) {
        super(key, callbackGet, callbackSet);
        this.m_defaultValue = defaultVal;
    }

    public String getDefaultValue() {
        return this.m_defaultValue;
    }

    @Override
    public String getValueString() {
        return this.getValue();
    }

    @Override
    public float getValueFloat() {
        return PZMath.tryParseFloat(this.getValue(), 0.0F);
    }

    @Override
    public boolean getValueBool() {
        return StringUtils.tryParseBoolean(this.getValue());
    }

    @Override
    public void setValue(String val) {
        this.trySetValue(val);
    }

    @Override
    public void setValue(float val) {
        this.trySetValue(String.valueOf(val));
    }

    @Override
    public void setValue(boolean val) {
        this.trySetValue(val ? "true" : "false");
    }

    @Override
    public AnimationVariableType getType() {
        return AnimationVariableType.String;
    }

    @Override
    public boolean canConvertFrom(String val) {
        return true;
    }

    public interface CallbackGetStrongTyped extends AnimationVariableSlotCallback.CallbackGet<String> {
    }

    public interface CallbackSetStrongTyped extends AnimationVariableSlotCallback.CallbackSet<String> {
    }
}
